package models

import (
	"github.com/jinzhu/gorm"
)

type User struct {
	ID   string `gorm:"primary_key;type:INT(20)"`
	Age  int32  `gorm:"type:INT(20)"`
	Name string `gorm:"type:VARCHAR(256)"`
	Desc string `gorm:"type:VARCHAR(256)"`
}

func (User) TableName() string {
	return "user"
}
func GetUser(id string) (*User, error) {
	u := &User{
		ID: id,
	}
	err := db.First(u).Error
	if err != nil && err != gorm.ErrRecordNotFound {
		return nil, err
	}
	return u, nil
}
